From 12e480b4f9474e7517c8f1b8c9c8421c511ed5b9 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Mon, 14 May 2012 14:35:49 +0000 Subject: [PATCH] tsteven fixes a horrible hack of mine in kml.c. Replace invalid low-order characters in XML with whitespace in all XML files, including KML. Revert hack in kml.c Fix LineStyles test files which come from TPO3. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4179 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/kml.c | 13 +------------ gpsbabel/reference/LineStyles.gpx | 4 ++-- gpsbabel/reference/LineStyles.kml | 8 ++++---- gpsbabel/util.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/gpsbabel/kml.c b/gpsbabel/kml.c index 4d9ee0dbb..ccd023c09 100644 --- a/gpsbabel/kml.c +++ b/gpsbabel/kml.c @@ -1473,18 +1473,7 @@ static void kml_waypt_pr(const waypoint* waypointp) xfree(odesc); } else { if (strcmp(waypointp->shortname, waypointp->description)) { - // This is a hack. The entitizer code really should catch this, - // but this is the low risk fix for now - just toss bad chars. - int j; - char* t = xstrdup(waypointp->description); - for (j = 0; t[j] != 0; j++) { - if (t[j] < ' ') { - t[j] = ' '; - } - } - - kml_write_xmle("description", t); - xfree(t); + kml_write_xmle("description", waypointp->description); } } diff --git a/gpsbabel/reference/LineStyles.gpx b/gpsbabel/reference/LineStyles.gpx index 8168e13b4..acdf9b872 100644 --- a/gpsbabel/reference/LineStyles.gpx +++ b/gpsbabel/reference/LineStyles.gpx @@ -81,8 +81,8 @@ NOTE 1 - 12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions?? - 12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions?? + 12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions?? + 12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions?? NOTE 2 diff --git a/gpsbabel/reference/LineStyles.kml b/gpsbabel/reference/LineStyles.kml index 86137c815..6f3c7bc6a 100644 --- a/gpsbabel/reference/LineStyles.kml +++ b/gpsbabel/reference/LineStyles.kml @@ -187,7 +187,7 @@ NOTE 1 - 12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions?? + 12 test lines - see notes with GPX sample!! four line widths for solid red two line widths for dashed red seven colors for medium width Note that line names have nothing at all to do with line style attributes! These are named for convenient cross-reference, but keep in mind that "red med" is a line label and "Red Medium" is a style label. Waypoints are generated by Topo to exactly match the first track point. Apparently only GPX and KML output from GPSBabel retain track descriptions?? #waypoint -122.277670,37.522060 @@ -195,7 +195,7 @@ NOTE 2 - how GPX from GPSBabel shows Topo track desc as of 2012: (line name and line style are NOT related to actual color or width) <trk> <name>red line</name> <desc>Style=red med, Width=3, Dashed=0, Color=#ff0000</desc> <number>1</number> <trkseg> ... (Topo menu colors are stored in the file as web-style hex RGB) Red=#ff0000, Yellow=#ffff00, Green=#008000, Blue=#000080, Purple=#800080, Black=#000000, White=#ffffff (Topo solid line widths: Hairline=1, Thin=2, Medium=3, Thick=4) (Topo dashed line widths: Hairline=1, Thin=2) SRE's tpo.c mod stuffs Style/Width/Dashed/Color fields into "desc" field under the assumption that something will post-process GPX or KML output and move information from desc to private extensions (solid lines have "Dashed=0", can have width of 1=hairline to 4=thick) (dashed lines have "Dashed=1", can only have width of 1=hairline or 2=thin) + how GPX from GPSBabel shows Topo track desc as of 2012: (line name and line style are NOT related to actual color or width) <trk> <name>red line</name> <desc>Style=red med, Width=3, Dashed=0, Color=#ff0000</desc> <number>1</number> <trkseg> ... (Topo menu colors are stored in the file as web-style hex RGB) Red=#ff0000, Yellow=#ffff00, Green=#008000, Blue=#000080, Purple=#800080, Black=#000000, White=#ffffff (Topo solid line widths: Hairline=1, Thin=2, Medium=3, Thick=4) (Topo dashed line widths: Hairline=1, Thin=2) SRE's tpo.c mod stuffs Style/Width/Dashed/Color fields into "desc" field under the assumption that something will post-process GPX or KML output and move information from desc to private extensions (solid lines have "Dashed=0", can have width of 1=hairline to 4=thick) (dashed lines have "Dashed=1", can only have width of 1=hairline or 2=thin) #waypoint -122.284910,37.522349 @@ -203,7 +203,7 @@ NOTE 3 - how KML from GPSBabel shows Topo track desc as of 2012: (see important notes with GPX sample, all of them apply here!) (note that GPSBabel forces all track styles to be the same - why?) <Folder> <name>Tracks</name> <Folder> <name>red line</name> <snippet/> <description> <![CDATA[<table> <tr><td><b>Description</b> Style=Red Medium, Width=3, Dashed=0, Color=#ff0000 </td></tr> <tr><td><b>Distance</b> 1.3 mi </td></tr> </table>]]> </description> <Folder> <name>Points</name> <Placemark> <name>red line-0</name> ... + how KML from GPSBabel shows Topo track desc as of 2012: (see important notes with GPX sample, all of them apply here!) (note that GPSBabel forces all track styles to be the same - why?) <Folder> <name>Tracks</name> <Folder> <name>red line</name> <snippet/> <description> <![CDATA[<table> <tr><td><b>Description</b> Style=Red Medium, Width=3, Dashed=0, Color=#ff0000 </td></tr> <tr><td><b>Distance</b> 1.3 mi </td></tr> </table>]]> </description> <Folder> <name>Points</name> <Placemark> <name>red line-0</name> ... #waypoint -122.288962,37.522691 @@ -211,7 +211,7 @@ NOTE 4 - how MapSource 6.16.3 adds color to a track as of 2012: (color choices are Dark Gray, Red, Green, Yellow, Blue, Magenta, Cyan, White, Transparent) (should be easy to turn desc tag into their extension, but better to directly write track styles) <trk> <name>Hwy 50 from Placerville</name> <extensions> <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"> <gpxx:DisplayColor>Red</gpxx:DisplayColor> </gpxx:TrackExtension> </extensions> <trkseg> ... + how MapSource 6.16.3 adds color to a track as of 2012: (color choices are Dark Gray, Red, Green, Yellow, Blue, Magenta, Cyan, White, Transparent) (should be easy to turn desc tag into their extension, but better to directly write track styles) <trk> <name>Hwy 50 from Placerville</name> <extensions> <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"> <gpxx:DisplayColor>Red</gpxx:DisplayColor> </gpxx:TrackExtension> </extensions> <trkseg> ... #waypoint -122.272938,37.522105 diff --git a/gpsbabel/util.c b/gpsbabel/util.c index 0be028193..65460b3ab 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -1699,6 +1699,37 @@ entity_types stdentities[] = { { "<", "<", 0 }, { ">", ">", 0 }, { "\"", """, 0 }, + { "\x01", " ", 1 }, // illegal xml 1.0 character + { "\x02", " ", 1 }, // illegal xml 1.0 character + { "\x03", " ", 1 }, // illegal xml 1.0 character + { "\x04", " ", 1 }, // illegal xml 1.0 character + { "\x05", " ", 1 }, // illegal xml 1.0 character + { "\x06", " ", 1 }, // illegal xml 1.0 character + { "\x07", " ", 1 }, // illegal xml 1.0 character + { "\x08", " ", 1 }, // illegal xml 1.0 character + // { "\x09", " ", 1 }, legal xml 1.0 character + // { "\x0a", " ", 1 }, legal xml 1.0 character + { "\x0b", " ", 1 }, // illegal xml 1.0 character + { "\x0c", " ", 1 }, // illegal xml 1.0 character + // { "\x0d", " ", 1 }, legal xml 1.0 character + { "\x0e", " ", 1 }, // illegal xml 1.0 character + { "\x0f", " ", 1 }, // illegal xml 1.0 character + { "\x10", " ", 1 }, // illegal xml 1.0 character + { "\x11", " ", 1 }, // illegal xml 1.0 character + { "\x12", " ", 1 }, // illegal xml 1.0 character + { "\x13", " ", 1 }, // illegal xml 1.0 character + { "\x14", " ", 1 }, // illegal xml 1.0 character + { "\x15", " ", 1 }, // illegal xml 1.0 character + { "\x16", " ", 1 }, // illegal xml 1.0 character + { "\x17", " ", 1 }, // illegal xml 1.0 character + { "\x18", " ", 1 }, // illegal xml 1.0 character + { "\x19", " ", 1 }, // illegal xml 1.0 character + { "\x1a", " ", 1 }, // illegal xml 1.0 character + { "\x1b", " ", 1 }, // illegal xml 1.0 character + { "\x1c", " ", 1 }, // illegal xml 1.0 character + { "\x1d", " ", 1 }, //illegal xml 1.0 character + { "\x1e", " ", 1 }, //illegal xml 1.0 character + { "\x1f", " ", 1 }, //illegal xml 1.0 character { NULL, NULL, 0 } }; -- 2.30.2